Add support for an attempt to connect to existing Queue on API side to reduce slow requests number #133
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
problem
The very first request to Queue API is slow due to sending a list of test files from the disk. The bigger the test files list the slower is request. For a few thousand test files it can take 1+ second.
When a lot of requests from parallel CI nodes starting at the same time hit the Knapsack Pro API this can lead to slower performance of the API because requests with a list of test files can be slow. This leads to compound effect and degradation of API performance for very large projects using ~100+ parallel CI nodes.
When you use RSpec split by test examples feature then each parallel CI node must generate a JSON report with test example ids in order to prepare a list of test files that must be sent to API. This can be slow. By introducing an attempt to connect to the existing Queue on the API side we can avoid this slow operation of reading test files from disk or from JSON report for RSpec test examples.
Only the very first request (or a few concurrent requests from parallel CI nodes that hit API at the same time) will start 2nd request responsible for initializing the Queue on the API side based on a list of test files from disk (reading test files is slow operation especially for RSpec split by examples feature).
solution
Thanks to the above we can significantly reduce the number of slow requests and make the overall API more stable.
We can also start running tests faster for most parallel CI nodes that will start work after the queue was already initialized on the API side. This reduces start time by a few seconds or even more for the large test suites that use RSpec split by test examples feature.
WARNING ABOUT BUG
This PR accidentally introduced a bug in RSpec split by test examples feature. Here is the fix: #135